package com.intellagric.controller.agritech.controller;

import com.intellagric.common.pojo.LayuiDataGridResult;
import com.intellagric.common.pojo.ResponseMessage;
import com.intellagric.module.agritech.AgtArticleVo;
import com.intellagric.pojo.AgtArticle;
import com.intellagric.service.agritech.ArticleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * @Author: cwq
 * @Date: 2019/2/22 22:16
 * @Description:
 */
@RequestMapping("/api/agt_article")
@Controller
public class ArticleController {

    @Autowired
    private ArticleService articleService;

    @RequestMapping("/add")
    @ResponseBody
    public ResponseMessage add(AgtArticle article) {
        return articleService.addArticle(article);
    }

    @RequestMapping("/delete")
    @ResponseBody
    public ResponseMessage delete(String id) {
        return articleService.deleteArticle(id);
    }

    @RequestMapping("/edit")
    @ResponseBody
    public ResponseMessage edit(AgtArticle article) {
        return articleService.editArticle(article);
    }

    @RequestMapping("/{id}")
    @ResponseBody
    public AgtArticle get(@PathVariable String id) {
        return articleService.getArticleById(id);
    }

    @RequestMapping("/list")
    @ResponseBody
    public LayuiDataGridResult getList() {
        return articleService.getArticleList();
    }

    @RequestMapping("/query")
    @ResponseBody
    public LayuiDataGridResult getListByVo(AgtArticleVo agtArticleVo, int page, int limit) {
        return articleService.getArticleListByVo(agtArticleVo, page, limit);
    }

    @RequestMapping("/page")
    @ResponseBody
    public LayuiDataGridResult getPage(int page,int limit) {
        return articleService.getArticleByPage(page, limit);
    }
}
